package com.zx.flow.api.execute.response;

import lombok.Getter;

/**
 * @version v1.0
 * @Project: lab_000_base_web
 * @Title: ResponseStaus
 * @Description: 统一接口响应状态码
 * @author: zhangxue01
 * @date: 2020-9-18 21:04:38
 * @company: zhangxue
 * @Copyright: Copyright (c) 2015
 */
@Getter
public enum ResponseStatus {
    OK("200", "正确"),
    FLOW_ERROR_400("400", "请求错误"),
    FLOW_ERROR_401("401", "未经授权的请求"),
    FLOW_ERROR_402("402", "没有访问权限"),
    FLOW_ERROR_403("403", "xxxxxxxxx"),
    FLOW_ERROR_404("404", "请求的资源未不到"),

    FLOW_ERROR_500("500", "服务器内部错误"),
    FLOW_ERROR_502("502", "服务器正忙，请稍后再试"),
    FLOW_ERROR_503("503", "服务器正忙，请稍后再试"),
    FLOW_ERROR_504("504", "请求超时"),

    FLOW_ERROR_701("701", "参数不正确"),
    FLOW_ERROR_702("702", "系统错误"),
    FLOW_ERROR_703("703", "配置错误"),
    FLOW_ERROR_710("710", "token校验失败"),

    FLOW_ERROR_801("801", "流程处理失败"),
    FLOW_ERROR_802("802", "流程处理异常"),


    FLOW_ERROR_999("999", "未知异常");


    private String code;
    private String msg;

    private ResponseStatus(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResponseStatus getByCode(Integer code) {
        for (ResponseStatus responseStaus : ResponseStatus.values()) {
            if (responseStaus.getCode().equals(code)) {
                return responseStaus;
            }
        }
        return null;
    }


    public static void main(String[] args) {
        for (ResponseStatus value : ResponseStatus.values()) {
            System.out.println(
                    "@ApiResponse(responseCode = \"" + value.getCode() + "\", description = \"" + value.getMsg()
                            + "\")");
        }
    }
}
